
package com.seekting.study;

import java.util.concurrent.atomic.AtomicBoolean;

public class AtomicBooleanStudy {

    public static void main(String[] args) {
        final AtomicBoolean atomicBoolean = new AtomicBoolean(true);
        System.out.print("ab");
        System.out.print("\n");
        System.out.print("c");
        Runnable runnable = new Runnable() {

            boolean t = true;

            @Override
            public void run() {
                if (atomicBoolean.compareAndSet(true, false)) {
                    System.out.println("xxx");
                }
                if (t) {
                    t = false;
                    System.out.println("ttt");
                }
            }
        };

        new Thread(runnable).start();
        boolean test = atomicBoolean.getAndSet(false);
        atomicBoolean.lazySet(true);
        test = atomicBoolean.getAndSet(true);
        test = atomicBoolean.getAndSet(false);

    }
}
